create user PBT identified by PBT 
default tablespace USERS 
temporary tablespace temp;

grant all privileges to PBT;

create table SUBSCRIBER (
  id number not null,
  MSISDN varchar(20) not null,
  IMSI varchar(30) not null,
  STATUS number not null,
  SUBSCRIPTION_ID number not null,
  UPDATE_DATE date not null,
  CONSTRAINT SUBSCRIBER_PK PRIMARY KEY(id)  
);

create table SUBSCRIPTION (
  id number not null,
  NAME varchar(20) not null,
  IS_SELLABLE number not null,
  constraint SUBSCRIBTION_PK primary key(id)  
);

create index SUBSCRIPTION_NAME on SUBSCRIPTION(name);

CREATE TABLE EVENTS
(
   ID number PRIMARY KEY NOT NULL,
   SUBSCRIBER_ID number NOT NULL,
   EVENT_DATE date NOT NULL,
   TYPE number NOT NULL,
   CHARGE number NOT NULL,
   AMOUNT number,
   UOM number NOT NULL
);

CREATE OR REPLACE TRIGGER events_trg 
BEFORE INSERT ON events
FOR EACH ROW
BEGIN
  SELECT events_seq.NEXTVAL
  INTO   :new.id
  FROM   dual;
END;

ALTER TRIGGER events_trg ENABLE;